/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frontera;

import entidad.Persistencia;
import javax.swing.JPanel;

/**
 *
 * @author Alexander
 */
public class FramePrincipal extends javax.swing.JFrame {

    /**
     * Creates new form FramePrincipal
     */
    public FramePrincipal() {
        initComponents();
    }

    public void cambiarPanel(JPanel panel) {
        jPanel_Principal.setVisible(false);
        jPanel_Principal.removeAll();
        jPanel_Principal.add(panel);
        jPanel_Principal.setSize(panel.getPreferredSize());
        jPanel_Principal.setVisible(true);
        this.setSize(this.getPreferredSize());
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel_Principal = new javax.swing.JPanel();
        jToolBar1 = new javax.swing.JToolBar();
        boton_Registrar = new javax.swing.JButton();
        boton_Historico = new javax.swing.JButton();
        boton_Actual = new javax.swing.JButton();
        boton_Reporte = new javax.swing.JButton();
        boton_Prediccion = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jPanel_Principal.setLayout(new java.awt.BorderLayout());

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);

        boton_Registrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/frontera/iconos/Agregar.png"))); // NOI18N
        boton_Registrar.setText("Registrar");
        boton_Registrar.setFocusable(false);
        boton_Registrar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Registrar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        boton_Registrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_RegistrarActionPerformed(evt);
            }
        });
        jToolBar1.add(boton_Registrar);

        boton_Historico.setIcon(new javax.swing.ImageIcon(getClass().getResource("/frontera/iconos/Historico.png"))); // NOI18N
        boton_Historico.setText("Historico");
        boton_Historico.setFocusable(false);
        boton_Historico.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Historico.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        boton_Historico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_HistoricoActionPerformed(evt);
            }
        });
        jToolBar1.add(boton_Historico);

        boton_Actual.setIcon(new javax.swing.ImageIcon(getClass().getResource("/frontera/iconos/Actual.png"))); // NOI18N
        boton_Actual.setText("Actual");
        boton_Actual.setFocusable(false);
        boton_Actual.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Actual.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        boton_Actual.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_ActualActionPerformed(evt);
            }
        });
        jToolBar1.add(boton_Actual);

        boton_Reporte.setIcon(new javax.swing.ImageIcon(getClass().getResource("/frontera/iconos/Reporte.png"))); // NOI18N
        boton_Reporte.setText("Reporte");
        boton_Reporte.setFocusable(false);
        boton_Reporte.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Reporte.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        boton_Reporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_ReporteActionPerformed(evt);
            }
        });
        jToolBar1.add(boton_Reporte);

        boton_Prediccion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/frontera/iconos/prediccion.png"))); // NOI18N
        boton_Prediccion.setText("Prediccion");
        boton_Prediccion.setFocusable(false);
        boton_Prediccion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Prediccion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        boton_Prediccion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_PrediccionActionPerformed(evt);
            }
        });
        jToolBar1.add(boton_Prediccion);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE)
            .addComponent(jPanel_Principal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel_Principal, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void boton_RegistrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_RegistrarActionPerformed
        cambiarPanel(new PanelRegistrar());
        this.setResizable(false);
    }//GEN-LAST:event_boton_RegistrarActionPerformed

    private void boton_HistoricoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_HistoricoActionPerformed
        this.cambiarPanel(new PanelHistoriograma());
        this.setResizable(true);
    }//GEN-LAST:event_boton_HistoricoActionPerformed

    private void boton_ActualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_ActualActionPerformed
        this.cambiarPanel(new panelActual());
        this.setResizable(false);
    }//GEN-LAST:event_boton_ActualActionPerformed

    private void boton_ReporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_ReporteActionPerformed
        this.cambiarPanel(new panelReporte());
        this.setResizable(false);
    }//GEN-LAST:event_boton_ReporteActionPerformed

    private void boton_PrediccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_PrediccionActionPerformed
        this.cambiarPanel(new panelPrediccion());
        this.setResizable(true);
    }//GEN-LAST:event_boton_PrediccionActionPerformed

    
    private static Persistencia sistema = Persistencia.getInstance();
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FramePrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FramePrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FramePrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FramePrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FramePrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton boton_Actual;
    private javax.swing.JButton boton_Historico;
    private javax.swing.JButton boton_Prediccion;
    private javax.swing.JButton boton_Registrar;
    private javax.swing.JButton boton_Reporte;
    private javax.swing.JPanel jPanel_Principal;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
}
